cssselector: Fix max_selector usage
authorAlexander Mikhaylenko <alexm@gnome.org>
Mon, 3 May 2021 09:41:15 +0000 (14:41 +0500)
committerAlexander Mikhaylenko <alexm@gnome.org>
Tue, 4 May 2021 07:34:29 +0000 (12:34 +0500)
Reverts 2ae8ace78499074a4d0ea6d9272cda0e6b9d5807 other than code style
fixes.

Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/3100

gtk/gtkcssselector.c

index 951fbd1060e7c2bcf825763cc412b4c9782602fc..b92556ad6fc01d999321f72077a16b83d82bae4b 100644 (file)
@@ -2102,7 +2102,6 @@ subdivide_infos (GByteArray                 *array,
                  guint                       n_infos,
                  gint32                      parent_offset)
 {
-  const GtkCssSelector *max_selector = NULL;
   GtkCssSelectorRuleSetInfo **matched_infos;
   guint n_matched = 0;
   GtkCssSelectorRuleSetInfo **remaining_infos;
@@ -2110,6 +2109,7 @@ subdivide_infos (GByteArray                 *array,
   GHashTable *ht;
   gint32 tree_offset;
   GtkCssSelectorTree *tree;
+  GtkCssSelector max_selector;
   GHashTableIter iter;
   guint max_count;
   gpointer key, value;
@@ -2139,16 +2139,16 @@ subdivide_infos (GByteArray                 *array,
       GtkCssSelector *selector = key;
       if (GPOINTER_TO_UINT (value) > max_count ||
           (GPOINTER_TO_UINT (value) == max_count &&
-           gtk_css_selector_compare_one (selector, max_selector) < 0))
+           gtk_css_selector_compare_one (selector, &max_selector) < 0))
         {
           max_count = GPOINTER_TO_UINT (value);
-          max_selector = selector;
+          max_selector = *selector;
         }
     }
 
   tree = alloc_tree (array, &tree_offset);
   tree->parent_offset = parent_offset;
-  tree->selector = *max_selector;
+  tree->selector = max_selector;
 
   /* Allocate maximum for both of them */
   /* TODO: Potentially dangerous? */
@@ -2160,9 +2160,9 @@ subdivide_infos (GByteArray                 *array,
     {
       GtkCssSelectorRuleSetInfo *info = infos[i];
 
-      if (gtk_css_selectors_has_initial_selector (info->current_selector, max_selector))
+      if (gtk_css_selectors_has_initial_selector (info->current_selector, &max_selector))
        {
-         info->current_selector = gtk_css_selectors_skip_initial_selector (info->current_selector, max_selector);
+         info->current_selector = gtk_css_selectors_skip_initial_selector (info->current_selector, &max_selector);
          if (info->current_selector == NULL)
            {
              /* Matches current node */